import {IReference} from "../ReferencePool/IReference";
import {BaseEventArgs} from "./BaseEventArgs";
import {ReferencePool} from "../ReferencePool/ReferencePool";

export class Event<T extends BaseEventArgs> implements IReference{

    static Create<T extends BaseEventArgs>(sender,e:T):Event<T>{
        let eventNode:Event<T> = ReferencePool.Acquire(Event) as Event<T>;
        eventNode._sender = sender;
        eventNode._eventArgs = e;
        return eventNode;
    }

    private _sender:any;
    private _eventArgs:T;

    constructor() {
        this._sender = null;
        this._eventArgs = null;
    }
    get sender(): any {
        return this._sender;
    }

    get eventArgs(): T {
        return this._eventArgs;
    }

    Clear(): void {
        this._sender = null;
        this._eventArgs = null;
    }

}